package com.think.teaching.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.think.teaching.model.PaperZone;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * 试卷分区 Mapper 接口
 * </p>
 *
 * @author think
 * @since 2020-08-12
 */
public interface PaperZoneMapper extends BaseMapper<PaperZone> {

	@Select("SELECT id,zone_index,weight,type FROM paper_zone pz WHERE paper_id=#{id}")
	@Result(column = "id",property = "questions",
	one = @One(select = "com.think.teaching.mapper.PaperZoneMapper.getPaperZoneQuestions" ))
	Map<String, Object> getPaperZoneDetails(Integer id);
	
	@Select("SELECT q.id,q.content,q.type FROM question q WHERE q.id IN (SELECT question_id FROM paper_question WHERE zone_id=#{id})  AND q.delflag=0")
	@Result(column = "id",property = "id")
	@Result(column = "id",property = "selections",
	one = @One(select = "com.think.teaching.mapper.QuestionSelectionMapper.getQuestionSelections" ))
	Map<String, Object> getPaperZoneQuestions(Integer id);
}
